<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

require_once(dirname(__FILE__).'/../lib/BasesfGuardAuthActions.class.php');

/**
 *
 * @package    symfony
 * @subpackage plugin
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: actions.class.php 23319 2009-10-25 12:22:23Z Kris.Wallsmith $
 */
class sfGuardAuthActions extends BasesfGuardAuthActions
{
	public function executeSecure($request)
	{
		$this->getResponse()->setStatusCode(403);
		$this->setLayout(false);
	}

	public function executeRetrieve($request) {
		$user = sfGuardUser::retrieveAccountByUsername($request->getParameter('email'));
		if ($user == NULL)
		{
			$this->getUser()->setFlash('usnf','Пользователь с таким логином не найден');
			$this->redirect('@sf_guard_password');
		}
		else
		{
			// password generating
		 $length  = 8;
		 $alphabet  = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
		 $this->newpassword = substr(str_shuffle($alphabet), 0, $length);
		 $user->setPassword($this->newpassword);
		 //$this->user->save();
		 
		 // password sending via e-mail
		 
$message = $this->getMailer()->compose(
      array('no-reply@molodejka.org.ua' => 'No-reply'),
      'aluminium1989@hotmail.com',
      'Jobeet affiliate token',
      <<<EOF
Your Jobeet affiliate account has been activated.
 
Your token is no.
 
The Jobeet Bot.
EOF
    );
 
    $this->getMailer()->send($message);
		 
		 
		 
		 
//		 $transport = Swift_SmtpTransport::newInstance('mx1.mirohost.net', 25)
//  			->setUsername('no-reply')
//  			->setPassword('q6UrZorv');  			
//
//		$mailer = Swift_Mailer::newInstance($transport);
//
//		$message = Swift_Message::newInstance('Wonderful Subject')
//  ->setFrom(array('no-reply@molodejka.org.ua' => 'no-reply'))
//  ->setTo(array('aluminium1989@hotmail.com'))
//  ->setBody('Here is the message itself');
//  
//  $this->result = $mailer->send($message);
		 
		 
//		 $message = $this->getMailer()->compose(
//		 array('no-reply@molodejka.org.ua'=>'no-reply'),
//		 'aluminium1989@hotmail.com',		 
//		 'Восстановление пароля к аккаунту на сайте molodejka.org.ua',		 		 		 
//		 'HELLO WORLD');
//		 
//		 $this->result = $this->getMailer()->send($message);
		 
		}
	}
}